import http from "@/api/config/http";
import { IQuery, ITableResponse } from "@/interface/IAxios";
import { IUser } from "./types";

// 查询用户列表
export function listUser(query: IQuery): Promise<ITableResponse<IUser>> {
  return http.request({
    url: "/system/user/list",
    method: "get",
    params: query
  });
}
// 新增用户
export function addUser(data: Partial<IUser>) {
  return http.request({
    url: "/system/user",
    method: "post",
    data
  });
}

// 删除用户
export function delUser(userId: string[]) {
  return http.request({
    url: `/system/user/${userId}`,
    method: "delete"
  });
}

// 修改用户
export function updateUser(data: Partial<IUser>) {
  return http.request({
    url: "/system/user",
    method: "put",
    data
  });
}
// 查询用户详细
export function getUser(userId: string) {
  return http.request({
    url: `/system/user/${userId}`,
    method: "get"
  });
}
// 用户密码重置
export function updateUserPwd(oldPassword: string, newPassword: string) {
  const data = {
    oldPassword,
    newPassword
  };
  return http.request({
    url: "/system/user/profile/updatePwd",
    method: "put",
    params: data
  });
}

// 修改用户个人信息
export function updateUserProfile(data: IUser) {
  return http.request({
    url: "/system/user/profile",
    method: "put",
    data
  });
}

export const saasInfo = () => {
  return http.request({
    url: "/store/store/saasInfo",
    method: "get"
  });
};
